package com.DaoImpl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import com.dao.StuDao;
import com.until.Dbutil;

public class StuDaoImpl implements StuDao {
	Connection conn = null;
	PreparedStatement pst = null;
	@Override
	public void remove(String StuNo) throws SQLException {
		String sql ="delete from studentt where  StuNo=?";
		conn = Dbutil.getConn();
		pst = conn.prepareStatement(sql);
		pst.setString(1, StuNo);
		int num = pst.executeUpdate();		
		if(num>0){
			System.out.println("删除成功");
		}else{
			System.out.println("删除失败");
		}
		
	}
	
	@Override
	public int add(student s) throws SQLException {
		String sql = "INSERT INTO studentt VALUES(?,?,?,?,?)";
		conn =AliPool.getConn();
		pst = conn.prepareStatement(sql);
		pst.setString(1, s.getStu());
		pst.setString(2, s.getName());
		pst.setString(3, s.getSex());
		pst.setString(4, s.getAge());
		pst.setString(5, s.getBran());
		int rs = pst.executeUpdate();
		return rs;
	}

}
